Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class CTPHIEUTHUBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As CTPHIEUTHUDto)
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDCTPHIEUTHU As System.Int32)
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.xoa(IDCTPHIEUTHU)
 End Sub
 Public Sub sua(ByVal Dto As CTPHIEUTHUDto)
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoCTPHIEUTHU As CTPHIEUTHUdto = LayBangDTo(i, Dao) 
 aList.Add(dtoCTPHIEUTHU)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaMAPHIEUTHU( ByVal MAPHIEUTHU as System.String, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaMAPHIEUTHU(MAPHIEUTHU,IDCTPHIEUTHU)
 End Sub 
 Public Sub suaIDPHIEUTHU( ByVal IDPHIEUTHU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaIDPHIEUTHU(IDPHIEUTHU,IDCTPHIEUTHU)
 End Sub 
 Public Sub suaNGUOITHU( ByVal NGUOITHU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaNGUOITHU(NGUOITHU,IDCTPHIEUTHU)
 End Sub 
 Public Sub suaNGUOILAPPHIEU( ByVal NGUOILAPPHIEU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaNGUOILAPPHIEU(NGUOILAPPHIEU,IDCTPHIEUTHU)
 End Sub 
 Public Sub suaSOTIENTHU( ByVal SOTIENTHU as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaSOTIENTHU(SOTIENTHU,IDCTPHIEUTHU)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDCTPHIEUTHU)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDCTPHIEUTHU As System.Int32 )
 Dim dao As New CTPHIEUTHUDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDCTPHIEUTHU)
 End Sub 
 Public Function LayBangTable( ByVal IDCTPHIEUTHU As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(IDCTPHIEUTHU,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDCTPHIEUTHU As System.Int32) As IList
 Dim Dao As New CTPHIEUTHUDao(IDCTPHIEUTHU,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoCTPHIEUTHU As CTPHIEUTHUdto = LayBangDTo(i, Dao) 
 aList.Add(dtoCTPHIEUTHU)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDCTPHIEUTHU (ByVal IDCTPHIEUTHU As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDCTPHIEUTHU(IDCTPHIEUTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDCTPHIEUTHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDCTPHIEUTHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDCTPHIEUTHU (ByVal IDCTPHIEUTHU As System.Int32) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoIDCTPHIEUTHU(IDCTPHIEUTHU)
 End sub
 Public Function LayBangTableTheoMAPHIEUTHU (ByVal MAPHIEUTHU As System.String) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoMAPHIEUTHU(MAPHIEUTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoMAPHIEUTHU_like (ByVal MAPHIEUTHU As System.String ) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoMAPHIEUTHU_like (MAPHIEUTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoMAPHIEUTHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoMAPHIEUTHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoMAPHIEUTHU (ByVal MAPHIEUTHU As System.String) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoMAPHIEUTHU(MAPHIEUTHU)
 End sub
 Public Function LayBangTableTheoIDPHIEUTHU (ByVal IDPHIEUTHU As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDPHIEUTHU(IDPHIEUTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDPHIEUTHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoIDPHIEUTHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDPHIEUTHU (ByVal IDPHIEUTHU As System.Int32) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoIDPHIEUTHU(IDPHIEUTHU)
 End sub
 Public Function LayBangTableTheoNGUOITHU (ByVal NGUOITHU As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGUOITHU(NGUOITHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoNGUOITHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGUOITHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoNGUOITHU (ByVal NGUOITHU As System.Int32) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoNGUOITHU(NGUOITHU)
 End sub
 Public Function LayBangTableTheoNGUOILAPPHIEU (ByVal NGUOILAPPHIEU As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGUOILAPPHIEU(NGUOILAPPHIEU)
 Return Dao
 End Function
 Public Function LayBangTableTheoNGUOILAPPHIEU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoNGUOILAPPHIEU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoNGUOILAPPHIEU (ByVal NGUOILAPPHIEU As System.Int32) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoNGUOILAPPHIEU(NGUOILAPPHIEU)
 End sub
 Public Function LayBangTableTheoSOTIENTHU (ByVal SOTIENTHU As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoSOTIENTHU(SOTIENTHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoSOTIENTHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoSOTIENTHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoSOTIENTHU (ByVal SOTIENTHU As System.Int32) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoSOTIENTHU(SOTIENTHU)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDCTPHIEUTHU As System.Int32) As CTPHIEUTHUdto
 Dim Dao As New CTPHIEUTHUDao(IDCTPHIEUTHU, ketnoi)
 Dim dto As New CTPHIEUTHUdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDCTPHIEUTHU")) = False Then
 Dto.IDCTPHIEUTHU = Dao.Rows(0)("IDCTPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.IDCTPHIEUTHU")) = False Then
 Dto.IDCTPHIEUTHU = Dao.Rows(0)("CTPHIEUTHU.IDCTPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(0)("MAPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(0)("CTPHIEUTHU.MAPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(0)("IDPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(0)("CTPHIEUTHU.IDPHIEUTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("NGUOITHU")) = False Then
 Dto.NGUOITHU = Dao.Rows(0)("NGUOITHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.NGUOITHU")) = False Then
 Dto.NGUOITHU = Dao.Rows(0)("CTPHIEUTHU.NGUOITHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("NGUOILAPPHIEU")) = False Then
 Dto.NGUOILAPPHIEU = Dao.Rows(0)("NGUOILAPPHIEU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.NGUOILAPPHIEU")) = False Then
 Dto.NGUOILAPPHIEU = Dao.Rows(0)("CTPHIEUTHU.NGUOILAPPHIEU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("SOTIENTHU")) = False Then
 Dto.SOTIENTHU = Dao.Rows(0)("SOTIENTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.SOTIENTHU")) = False Then
 Dto.SOTIENTHU = Dao.Rows(0)("CTPHIEUTHU.SOTIENTHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("CTPHIEUTHU.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTPHIEUTHU.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("CTPHIEUTHU.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As CTPHIEUTHUdto
 Dim dto As New CTPHIEUTHUdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDCTPHIEUTHU")) = False Then
 Dto.IDCTPHIEUTHU = Dao.Rows(i)("IDCTPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.IDCTPHIEUTHU")) = False Then
 Dto.IDCTPHIEUTHU = Dao.Rows(i)("CTPHIEUTHU.IDCTPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(i)("MAPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.MAPHIEUTHU")) = False Then
 Dto.MAPHIEUTHU = Dao.Rows(i)("CTPHIEUTHU.MAPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(i)("IDPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.IDPHIEUTHU")) = False Then
 Dto.IDPHIEUTHU = Dao.Rows(i)("CTPHIEUTHU.IDPHIEUTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("NGUOITHU")) = False Then
 Dto.NGUOITHU = Dao.Rows(i)("NGUOITHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.NGUOITHU")) = False Then
 Dto.NGUOITHU = Dao.Rows(i)("CTPHIEUTHU.NGUOITHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("NGUOILAPPHIEU")) = False Then
 Dto.NGUOILAPPHIEU = Dao.Rows(i)("NGUOILAPPHIEU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.NGUOILAPPHIEU")) = False Then
 Dto.NGUOILAPPHIEU = Dao.Rows(i)("CTPHIEUTHU.NGUOILAPPHIEU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("SOTIENTHU")) = False Then
 Dto.SOTIENTHU = Dao.Rows(i)("SOTIENTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.SOTIENTHU")) = False Then
 Dto.SOTIENTHU = Dao.Rows(i)("CTPHIEUTHU.SOTIENTHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("CTPHIEUTHU.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTPHIEUTHU.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("CTPHIEUTHU.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As CTPHIEUTHUdto
 Dim dto As New CTPHIEUTHUdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New CTPHIEUTHUDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

